<%@page import="com.yjw.enity.Prod"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    
    <title>My JSP 'p.jsp' starting page</title>
     <link href="style/bootstrap.min.css" rel="stylesheet">


  </head>
  
  <body >
 
  <input  type="button"   value="查看天气"  id="myinput"/>
   <input  type="button"  value="看完毕"  id="myinput2"  style="display:none"/>
    <div   id="mybody"  style="display:none"></div  >
     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
     <script  type="text/javascript">
     $(document).ready(function(){
     	$("#myinput").click(function(){
     		$("#mybody").show();
     		$.get("g.jspx",function(xml){
     			$(xml).find("forecast_conditions").each(function(){
     				var week = $(this).find("day_of_week").attr("data");
     				var low = $(this).find("low").attr("data");
     				var high = $(this).find("high").attr("data");
     				var icon = $(this).find("icon").attr("data");
     				var con = $(this).find("condition").attr("data");
     				$("<div class="+"weather"+"><div>"+week+"</div><div>最低温度"+low+"</div><div>最高温度"+high+"</div><img src='http://www.google.com"+icon+"'/><div>天气状况"+con+"</div></div>").appendTo($("#mybody"));
     				$("#myinput").hide();
     				$("#myinput2").show();
     		});
     	});
     	});
     	$("#myinput2").click(function(){
     		$("#mybody").hide();
     		$("#myinput").show();
     		$("#myinput2").hide();
     		$(".weather").remove();
     	});
     });
     var xmlHttp;
     function createXMLHttpRequest(){
     	if(window.ActiveXObject){
     		xmlHttp = new  ActiveXObject("Microsoft.XMLHTTP");
     	}else {
     		xmlHttp = new  XMLHttpRequest();
     	}
     }
    // document.getElementById("city").onblur=function(){
     	//createXMLHttpRequest();
     //	var city = document.getElementById("city").value;
     //	city = encodeURIComponent(city);
     //	alert(city);
     //	xmlHttp.open("get","g.jspx?name="+city,true);
     //	xmlHttp.send();
     //}
     /*	var xmlHttp;
     	function  createXMLHttpRequest(){
     		if(window.ActiveXObject){
     			xmlHttp = new  ActiveXObject("Microsoft.XMLHTTP");
     		}else {
     			xmlHttp = new  XMLHttpRequest();
     		}
     	}
     	
     	function  sendmes(){
     		createXMLHttpRequest();
     		
     		xmlHttp.onreadystatechange = callback;
     		xmlHttp.open("get", "g.jspx", true);
     		xmlHttp.send();
     	}
     	function callback(){
     		if(xmlHttp.readyState==4){
     			if(xmlHttp.status==200){
     				var xml = xmlHttp.responseXML;
     				var weather = xml.getElementsByTagName("weather")[0];
			
			//得到情况1
			var conditions1 = weather.getElementsByTagName("forecast_conditions");
			for(var i = 0;i<4;i++){
			
				var week1 = conditions1[i].getElementsByTagName("day_of_week")[0];
			var data12 = week1.getAttribute("data");//得到周一
			
			var low1 = conditions1[i].getElementsByTagName("low")[0];
			var data13 = low1.getAttribute("data");//得到最低温度
			
			var high1 = conditions1[i].getElementsByTagName("high")[0];
			var data16 = high1.getAttribute("data");
				
			var icon2 = conditions1[i].getElementsByTagName("icon")[0];
			var data14 = icon2.getAttribute("data");//得到图片
			var condition1 = conditions1[i].getElementsByTagName("condition")[0];
			var data15 = condition1.getAttribute("data");//晴间多云
			var mydiv = document.createElement("div");
			//放周期
			var div1 = document.createElement("div");
			var weektext = document.createTextNode(data12);
			div1.appendChild(weektext);
			mydiv.appendChild(div1);
			//图片
			var div4 = document.createElement("div");
			var img = document.createElement("img");
			img.setAttribute("src","http://www.google.com"+data14);
			div4.appendChild(img);
			mydiv.appendChild(div4);
			//放最低温度
			var div2 = document.createElement("div");
			var diwen = document.createTextNode("最低温度"+data13);
			div2.appendChild(diwen);
			mydiv.appendChild(div2);
			//高温
			var div3 = document.createElement("div");
			var  gaowen = document.createTextNode("最高温度"+data16);
			div3.appendChild(gaowen);
			mydiv.appendChild(div3);
			document.getElementById("mybody").appendChild(mydiv);
			}
			document.getElementById("myinput").style.display="none";
     		
     	}else {
     		alert("cuowu");
     	}
     }
     	}*/
     </script>
  </body>
</html>
